home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / mediacenter / SetupMCERSSReader.exe / {app} / exCommon.js < prev    next >
Encoding:
Text File  |  2005-12-18  |  47.7 KB  |  1,554 lines

  1.     function IsMCEEnabled()
  2.     {
  3.         return true
  4.     }
  5.  
  6.     function Initialize()
  7.     {
  8.         if (nCurFocus == "SVP" || nCurFocus == "CVP" )
  9.         {
  10.             return
  11.         }
  12.  
  13.         SetFocus();
  14.     }
  15.  
  16.  
  17.     function Disable()
  18.     {
  19.         if (event.button == 2)
  20.             try
  21.             {
  22.                  window.external.MediaCenter.Dialog("right-click disabled","",1,30,true)      
  23.             }
  24.             catch(e)
  25.             {
  26.             }
  27.     }
  28.  
  29.  
  30.     /////////////////////////////////////////////////////////////////
  31.     // user selected item, navigate to it based on DestinationArray
  32.     function DoNavigation()
  33.     {
  34.         // make sure focus is not on a viewport
  35.         if ((nCurFocus == "SVP") || (nCurFocus == "CVP"))
  36.         {
  37.             return  
  38.         }
  39.  
  40.         try
  41.         {           
  42.             // if array element is not empty
  43.             if (aFocusTableArray[nCurFocus-1][10] != "")
  44.             {
  45.                 try
  46.                 {
  47.                     // try to run as a function; if element string is a link instead of a function, create an error
  48.                     eval(aFocusTableArray[nCurFocus-1][10]);
  49.                     
  50.                     // If element is a link starting with "http" it will not cause error;
  51.                     // so check if string starts with "http"; if so, treat as a link
  52.                     try 
  53.                     {
  54.                         var sArraySubStr = (aFocusTableArray[nCurFocus-1][10]).substring(0, 4)
  55.                         if (sArraySubStr == "http")
  56.                         {
  57.                             window.navigate(aFocusTableArray[nCurFocus-1][10]);
  58.                         }
  59.                         else
  60.                         {
  61.                             // Should keep navigation?
  62.                         }
  63.                     }
  64.                     catch(e)
  65.                     {
  66.                         // ignore error
  67.                     }
  68.                 }
  69.                 catch(e)
  70.                 {
  71.                     // if previous throws error, treat as a link
  72.                     window.navigate(aFocusTableArray[nCurFocus-1][10]);
  73.                 }
  74.             }
  75.         }
  76.         catch(e)
  77.         {
  78.             //ignore error
  79.         }
  80.     }
  81.  
  82.  
  83.     /////////////////////////////////////////////////////////////////
  84.     // focus on item in list based on nCurFocus value and user input
  85.     function SetFocus(nKey)
  86.     {
  87.         try
  88.         {
  89.             /////////////////////////////////////////////////////////////////////////////////
  90.             // reset mouse variable to nullify mouseover event, which can fire after keypress    
  91.             nMouseEvent = 0;
  92.  
  93.             //////////////////////////////////////////////////////////////////////////////////
  94.             // hold onto current focus in case it gets broken along the way
  95.  
  96.             var nPrevFocus = nCurFocus;
  97.             //////////////////////////////////////////////////////////////////////////////////
  98.             // update nCurFocus values based on key selection
  99.             // on first visit to page, nothing to do because nCurFocus is initialized
  100.  
  101.             //first, check if previous focus is on a viewport
  102.             if (nPrevFocus == "CVP")
  103.             {
  104.                 // check correct array for new focus item
  105.                 nCurFocus = aCustomViewportArray[nKey];
  106.             }
  107.             else if (nPrevFocus == "SVP")
  108.             {
  109.                 // check correct array for new focus item
  110.                 nCurFocus = aSharedViewportArray[nKey];
  111.             }
  112.             // if previous focus is not on a viewport, find new focus item in regular array
  113.             else
  114.             {
  115.                 if (nKey >= 0)
  116.                     nCurFocus = aFocusTableArray[nCurFocus-1][nKey];
  117.                     
  118.                 DontSetFocusOnSeparator(nKey);
  119.             }
  120.  
  121.             //////////////////////////////////////////////////////////////////////////////////
  122.             // user tried an illegal move, reset nCurFocus to known state
  123.             if (nCurFocus == -1)
  124.             {
  125.                 nCurFocus = nPrevFocus;
  126.                 strCurItemName = eval('item' + nCurFocus)
  127.                 if (eval(strCurItemName).scrollable == 'true')
  128.                     scrollElement(nCurFocus,nKey,17)
  129.                     
  130.                 return;
  131.             }
  132.             
  133.             DrawFocus(nPrevFocus, nCurFocus, (nKey >= 0));
  134.  
  135.             // Check if a right buttonlist button was clicked
  136.             if (nCurFocus > nOrdinaryItems)
  137.             {
  138.                 var nIndex;
  139.                 
  140.                 aSharedViewportArray[3] = nCurFocus;
  141.                 for (nIndex = 1; nIndex <= nOrdinaryItems; nIndex++)
  142.                     aFocusTableArray[nIndex -1][3] = nCurFocus;
  143.             }
  144.         }
  145.         catch(e)
  146.         {
  147.             //ignore error
  148.         }
  149.     }
  150.  
  151.  
  152.     function DontSetFocusOnSeparator(nKey)
  153.     {
  154.         var sClass;
  155.         var nSepFocus;
  156.         
  157.         try
  158.         {
  159.             sClass = eval('item' + nCurFocus + '.className');
  160.             if(sClass == 'btnright_sep')
  161.             {
  162.                 nSepFocus = nCurFocus;
  163.                 
  164.                 if(nKey == 0)
  165.                 {
  166.                     if(aFocusTableArray[nCurFocus-1][0] == -1)
  167.                     {
  168.                         scrollMenu(nCurFocus);
  169.                         nCurFocus = aFocusTableArray[nCurFocus-1][1];
  170.                     }
  171.                     else
  172.                         nCurFocus = aFocusTableArray[nCurFocus-1][0];
  173.                 }
  174.                 else
  175.                     nCurFocus = aFocusTableArray[nCurFocus-1][1];
  176.                     
  177.                 DrawFocus(nSepFocus, nCurFocus, false);
  178.             }
  179.         }
  180.         catch(e)
  181.         {
  182.         }
  183.     }
  184.     
  185.  
  186.     /////////////////////////////////////////////////////////////////
  187.     // DrawFocus
  188.     function DrawFocus(nPrevFocus, nCurFocus, bPlaySound)
  189.     {
  190.         try
  191.         {
  192.             // if enforced item was clicked
  193.             if (nPrevFocus == "ENF")
  194.             {
  195.                 var enforcedCurrent = aFocusTableArray[nCurFocus-1][9];
  196.             
  197.                 for (i=0; i < nOrdinaryItems; i++)
  198.                 {
  199.                     if (aFocusTableArray[i])
  200.                     {
  201.                         if (aFocusTableArray[i][9] == enforcedCurrent)
  202.                             eval('item' + (i + 1) + '.className=aFocusTableArray[i][5]')
  203.                             
  204.                         if (i == (nCurFocus - 1))
  205.                             eval('item' + (i + 1) + '.className=strEnforcedItemFocusStyle')
  206.                     }
  207.                 }
  208.             }
  209.             else if ((nPrevFocus == "SVP") || (nPrevFocus == "CVP"))
  210.             {
  211.                 // remove focus from viewport
  212.                 if (nPrevFocus == "SVP")
  213.                 {
  214.                     try
  215.                     {
  216.                        // add code to remove focus from viewport (not supported yet)
  217.                     }
  218.                     catch(e)
  219.                     {
  220.                         //Viewport is hidden; ignore error
  221.                     }
  222.                 }
  223.                 if (nPrevFocus == "CVP")
  224.                 {
  225.                     try
  226.                     {
  227.                        // add code to remove focus from viewport (not supported yet)
  228.                     }
  229.                     catch(e)
  230.                     {
  231.                         //Viewport is hidden; ignore error
  232.                     }
  233.                 }
  234.             }
  235.             else
  236.             {
  237.                 // remove focus from the previous item if different
  238.                 if (nPrevFocus != nCurFocus)
  239.                 {
  240.                     var strPrevItemName = eval('item' + nPrevFocus)
  241.                     
  242.                     // check if previous item is "enforced" (to indicate active category)
  243.                     try
  244.                     {
  245.                         if (strPrevItemName.id == strEnforcedItem)
  246.                         {
  247.                             eval(strPrevItemName).className = strEnforcedItemNoFocusStyle
  248.                         }
  249.                         else if (eval(strPrevItemName).checked != null)
  250.                         {
  251.                             if (eval(strPrevItemName).checked == 'yes')
  252.                                 eval(strPrevItemName).className = aFocusTableArray[nPrevFocus-1][5] + '_checked';
  253.                             else
  254.                                 eval(strPrevItemName).className = aFocusTableArray[PrevFocus-1][5];
  255.                         }
  256.                         else if (eval(strPrevItemName).trible != null)
  257.                         {
  258.                             eval(strPrevItemName).className=aFocusTableArray[nPrevFocus-1][5];
  259.                             body.focus();
  260.                         }
  261.                         else
  262.                         {
  263.                             if (eval(strPrevItemName).parentElement.className == 'btnMediaTD')
  264.                             {
  265.                                 eval(strPrevItemName).parentElement.children(1).className = 'btnMediaText_nofocus';
  266.                             }
  267.                             eval(strPrevItemName).className=aFocusTableArray[nPrevFocus-1][5];
  268.                         }
  269.                     }
  270.                     catch(e)
  271.                     {
  272.                         eval(strPrevItemName).className=aFocusTableArray[nPrevFocus-1][5];
  273.                     }
  274.                 }
  275.             }
  276.  
  277.             // Play "click" sound
  278.             if (bPlaySound)
  279.                 playFocusSound();
  280.  
  281.             // set buttons in current array to non-dormant, and buttons in other
  282.             // arrays to dormant
  283.             setDormant(nCurFocus, nPrevFocus);
  284.             
  285.             // if new item is shared viewport
  286.             if (nCurFocus == "SVP")
  287.             {
  288.                 // check if shared viewport is visible
  289.                 try
  290.                 {
  291.                     if (window.external.MediaCenter)
  292.                     {
  293.                         if (window.external.MediaCenter.SharedViewPort.Visible == true)
  294.                         {
  295.                             window.external.MediaCenter.SharedViewPort.Focus()// focus on shared viewport
  296.                         }
  297.                         else
  298.                         {
  299.                             // viewport is hidden, so reset focus to backup item in viewport array, by setting nKey to 4
  300.                             SetFocus(4)
  301.                         }
  302.                     }
  303.                     else
  304.                         SetFocus(4);
  305.                 }
  306.  
  307.                 catch(e)
  308.                 {
  309.                     SetFocus(4)
  310.                 }
  311.  
  312.                 return
  313.               }
  314.             //if new item is custom viewport
  315.             else if (nCurFocus == "CVP")
  316.             {
  317.                   // check if custom viewport is visible
  318.                 try
  319.                 {
  320.                     if (window.external.MediaCenter.CustomViewPort.visible == true)
  321.                     {
  322.                         window.external.MediaCenter.CustomViewPort.Focus() // focus on custom viewport
  323.                     }
  324.                     else
  325.                     {
  326.                         // viewport is hidden, so reset focus to backup item in viewport array, by setting nKey to 4
  327.                         SetFocus(4)
  328.                     }
  329.                 }
  330.  
  331.                 catch(e)
  332.                 {
  333.                     SetFocus(4)
  334.                 }
  335.  
  336.                 return
  337.             }
  338.  
  339.             // give focus to the new item
  340.             var strNewItemName = eval('item' + nCurFocus)
  341.             try
  342.             {
  343.                 // if array element is not empty
  344.                 if (aFocusTableArray[nCurFocus-1][11] != null)
  345.                 {    
  346.                     if (aFocusTableArray[nCurFocus-1][11] != "")
  347.                     {
  348.                         try
  349.                         {
  350.                             if (currentSelect)
  351.                                 currentSelect.innerHTML = aFocusTableArray[nCurFocus-1][11];
  352.                         }
  353.                         catch(e)
  354.                         {
  355.                             // ignore error
  356.                         }
  357.                     }
  358.                     else
  359.                     {
  360.                         try
  361.                         {
  362.                             if (currentSelect)
  363.                                 currentSelect.innerHTML = "";
  364.                         }
  365.                         catch(e)
  366.                         {
  367.                             // ignore error
  368.                         }
  369.                     }
  370.                 }
  371.                 else
  372.                 {
  373.                     try
  374.                     {
  375.                         if (currentSelect)
  376.                             currentSelect.innerHTML = "";
  377.                     }
  378.                     catch(e)
  379.                     {
  380.                         // ignore error
  381.                     }
  382.                 }
  383.                 if (aFocusTableArray[nCurFocus-1][12] != null)
  384.                 {    
  385.                     if (aFocusTableArray[nCurFocus-1][12] != "")
  386.                     {
  387.                         try
  388.                         {
  389.                             if (currentSelectTagLine)
  390.                                 currentSelectTagLine.innerHTML = aFocusTableArray[nCurFocus-1][12];
  391.                         }
  392.                         catch(e)
  393.                         {
  394.                             // ignore error
  395.                         }
  396.                     }
  397.                     else
  398.                     {
  399.                         if (currentSelectTagLine)
  400.                             currentSelectTagLine.innerHTML = "";
  401.                     }
  402.                 }
  403.                 else
  404.                 {
  405.                     if (currentSelectTagLine)
  406.                         currentSelectTagLine.innerHTML = "";
  407.                 }
  408.             }
  409.             catch(e)
  410.             {
  411.                 // ignore error
  412.             }
  413.  
  414.             // check if new item is "enforced" (to indicate active category)
  415.             try
  416.             {           
  417.                 if (strNewItemName.id == strEnforcedItem)
  418.                 {
  419.                     eval(strNewItemName).className = strEnforcedItemFocusStyle                    
  420.                 }
  421.                 else if (eval(strNewItemName).checked != null)
  422.                 {
  423.                     if (eval(strNewItemName).checked == 'yes')
  424.                         eval(strNewItemName).className = aFocusTableArray[nCurFocus-1][4] + '_checked';
  425.                     else
  426.                         eval(strNewItemName).className = aFocusTableArray[nCurFocus-1][4];
  427.                 }
  428.                 else if (eval(strNewItemName).trible != null)
  429.                 {
  430.                     eval(strNewItemName).className = aFocusTableArray[nCurFocus-1][4];
  431.                     tribleTabControl.SetInputFocus();
  432.                 }
  433.                 else
  434.                 {
  435.                     if (eval(strNewItemName).parentElement.className == 'btnMediaTD')
  436.                     {
  437.                         eval(strNewItemName).parentElement.children(1).className = 'btnMediaText_focus';
  438.                     }
  439.                     eval(strNewItemName).className = aFocusTableArray[nCurFocus-1][4];
  440.                 }
  441.             }
  442.             catch(e)
  443.             {
  444.                    eval(strNewItemName).className = aFocusTableArray[nCurFocus-1][4];
  445.             }
  446.                         
  447.             if (nCurFocus <= nOrdinaryItems)
  448.             {
  449.                 if (aFocusTableArray[nPrevFocus-1])
  450.                 {
  451.                         if (aFocusTableArray[nPrevFocus-1][9] != '')
  452.                         {
  453.                             if (aFocusTableArray[nCurFocus-1][9] == '')
  454.                             {
  455.                                 for (i=0; i < nOrdinaryItems; i++)
  456.                                 {
  457.                                     if (aFocusTableArray[i])
  458.                                     {
  459.                                     if (aFocusTableArray[i][9] == aFocusTableArray[nPrevFocus-1][9])
  460.                                     {
  461.                                         if ('item' + (i + 1) == strEnforcedItem)
  462.                                             eval('item' + (i + 1) + '.className=\'btn_nofocus_enforced_notcurrent\'')
  463.                                         else
  464.                                             eval('item' + (i + 1) + '.className=\'btn_nofocus\'')
  465.                                     }
  466.                                     }
  467.                                 }
  468.                             }
  469.                         }
  470.                         else
  471.                         {
  472.                             if (aFocusTableArray[nCurFocus-1][9] != '')
  473.                             {
  474.                                 for (i=0; i < nOrdinaryItems; i++)
  475.                                 {
  476.                                     if (aFocusTableArray[i])
  477.                                     {
  478.                                     if (aFocusTableArray[i][9] == aFocusTableArray[nCurFocus-1][9])
  479.                                     {
  480.                                         if (i != (nCurFocus - 1))
  481.                                         {
  482.                                             if ('item' + (i + 1) == strEnforcedItem)
  483.                                                 eval('item' + (i + 1) + '.className=\'btn_nofocus_enforced\'')
  484.                                             else
  485.                                                 eval('item' + (i + 1) + '.className=\'btn_nofocus_enforceGroup\'')
  486.                                         }
  487.                                     }
  488.                                     }
  489.                                 }                    
  490.                             }
  491.                         }
  492.                 }
  493.             }
  494.             
  495.             // determine if the page has a scrolling menu
  496.             try
  497.             {
  498.                 if  (strScrollPage == "yes")
  499.                 {
  500.                     scrollMenu(nCurFocus);
  501.                 }
  502.             }
  503.             catch (e)
  504.             {
  505.                 //ignore error
  506.             }
  507.  
  508.             // Custom (optional) function if needed; locate this function on the HTML page
  509.             try
  510.             {
  511.                 doOnFocus();
  512.             }
  513.             catch(e)
  514.             {
  515.                 //ignore error
  516.             }
  517.         }
  518.         catch(e)
  519.         {
  520.             //ignore error
  521.         }
  522.     }
  523.  
  524.  
  525.     /////////////////////////////////////////////////////////////////
  526.     // Scaling elements for page resize 
  527.     function onScaleEvent(vScale)
  528.     {
  529.         try
  530.         {
  531.             if (vScale != 1)
  532.                 document.styleSheets[0].href = 'cssscaled.css'
  533.                 
  534.             body.style.zoom=vScale;
  535.         }
  536.         catch(e)
  537.         {
  538.             // ignore error
  539.         }
  540.     }
  541.  
  542.  
  543.     /////////////////////////////////////////////////////////////////
  544.     // determine which remote control key the user selected 
  545.     // and take appropriate action
  546.     function onRemoteEvent(keyChar)
  547.     {
  548.         try
  549.         {
  550.             switch (keyChar)
  551.             {
  552.             case 0x26:  // Up button selected
  553.                 if(pFocusOnTextFrame())
  554.                     pScrollTextframe(keyChar);
  555.                 else
  556.                     SetFocus(0);
  557.                 return true;
  558.                 break;
  559.  
  560.             case 0x28:  // Down button selected
  561.                 if(pFocusOnTextFrame())
  562.                     pScrollTextframe(keyChar);
  563.                 else
  564.                     SetFocus(1);
  565.                 return true;
  566.                 break;
  567.  
  568.             case 0x25:  // Left button selected
  569.                 SetFocus(2);
  570.                 return true;
  571.                 break;
  572.  
  573.             case 0x27:  // Right button selected
  574.                 SetFocus(3);
  575.                 return true;
  576.                 break;
  577.  
  578.             case 0x0D:  // Enter button selected, execute link to content/page
  579.                 DoNavigation();
  580.                 return true;
  581.                 break;
  582.  
  583.             case 0x08:  // Keyboard Backspace selected
  584.                 return false;
  585.                 break;
  586.             case 0xA6:  // Browser Back button selected; Media Center will already perform a Back
  587.                 return false;      // navigation when this is pressed, but this case can be used to add additional
  588.                 break;             //functionality to Back button
  589.  
  590.             case 0x21:  // Page up (plus) selected; page-up scrolling menu
  591.                         // (currently works for keyboard pg-up, but not for remote key)
  592.                 if(pFocusOnTextFrame())
  593.                     pScrollTextframe(keyChar);
  594.                 else
  595.                     pageUp();
  596.                 return true;
  597.                 break;
  598.                 
  599.             case 0x22:  // Page down (minus) selected; page-down scrolling menu
  600.                         // (currently works for keyboard pg-down, but not for remote key)
  601.                 if(pFocusOnTextFrame())
  602.                     pScrollTextframe(keyChar);
  603.                 else
  604.                     pageDown();
  605.                 return true;
  606.                 break;
  607.  
  608.             default:
  609.                 return false;
  610.                 // ignore all other clicks
  611.             }
  612.         }
  613.         catch(ex)
  614.         {
  615.             logEx("onRemoteEvent(" + keyChar + ")", ex);
  616.         }
  617.     }
  618.     
  619.     
  620.     function pFocusOnTextFrame()
  621.     {
  622.         var sClassname;
  623.  
  624.         sClassname = ""
  625.         try
  626.         {
  627.             sClassname = eval("item" + nCurFocus + ".className");
  628.             if(sClassname.substring(0, 9) == "TextFrame")
  629.                 return true;
  630.         }
  631.         catch(e)
  632.         {
  633.         }
  634.         
  635.         return false;
  636.     }
  637.  
  638.  
  639.     function pScrollTextframe(keyChar)
  640.     {
  641.         var nTop;
  642.         var nHeight;
  643.         var nLines;
  644.         
  645.         nTop = listTable.style.top;
  646.         nTop = parseInt(nTop);
  647.  
  648.         nHeight = listTable.scrollHeight - listFrame.clientHeight;
  649.         
  650.         nPageHeight = Math.floor(listFrame.clientHeight / nScrollTextPixels) * nScrollTextPixels;
  651.         
  652.         switch(keyChar)
  653.         {
  654.             case 0x26: // arrow up
  655.                 nTop = nTop + nScrollTextPixels;
  656.                 break;
  657.         
  658.             case 0x28: // arrow down
  659.                 nTop = nTop - nScrollTextPixels;
  660.                 break;
  661.  
  662.             case 0x21: // page up
  663.                 nTop = nTop + nPageHeight;
  664.                 break;
  665.                 
  666.             case 0x22: // page down
  667.                 nTop = nTop - nPageHeight;
  668.                 break;
  669.         }
  670.         
  671.         if(nTop > 0)
  672.             nTop = 0;
  673.         if(nTop < -nHeight)
  674.             if(nHeight > 0)
  675.                 nTop = -nHeight;
  676.             else
  677.                 nTop = 0;
  678.  
  679.         listTable.style.top = nTop;
  680.  
  681.         resetScrollCounter();
  682.     }
  683.     
  684.     
  685.     function pGetScrollTotal()
  686.     {
  687.         var nHeight;
  688.         
  689.         nHeight = listTable.scrollHeight - listFrame.clientHeight;
  690.         if(nHeight < 0)
  691.             return 1;
  692.         else        
  693.             return Math.ceil(nHeight / nScrollTextPixels + 1);
  694.     }
  695.  
  696.  
  697.     function pGetScrollPosition()
  698.     {
  699.         var nTop;
  700.         
  701.         nTop = listTable.style.top;
  702.         nTop = parseInt(nTop);
  703.         
  704.         return Math.ceil(-nTop / nScrollTextPixels + 1);
  705.     }
  706.     
  707.     
  708.     function setScrollCounter()
  709.     {
  710.         // Make the scroll counter visible
  711.         itemCounterSpan.style.display = "block";
  712.         
  713.         // Show total number of scrollable lines in the counter
  714.         counterNum.innerText = 1;
  715.         counterTotal.innerText = pGetScrollTotal();
  716.         
  717.         resetScrollCounter();
  718.     }
  719.  
  720.  
  721.     function resetScrollCounter()
  722.     {
  723.         var nPosition;
  724.         var nTotal;
  725.         
  726.         // un-gray counter
  727.         itemCounterSpan.style.filter = "alpha(opacity=100)";
  728.         // display position of currently selected btn in counter
  729.         nTotal = pGetScrollTotal();
  730.         nPosition = pGetScrollPosition();
  731.         counterNum.innerText = nPosition;
  732.         // gray out up arrow if focus in on top button
  733.         if (nPosition <= 1)
  734.         {
  735.             arrowUp.disabled = true;
  736.             arrowUp.style.filter = "alpha(opacity=20)";
  737.         }
  738.         else
  739.         {
  740.             arrowUp.disabled = false;
  741.             arrowUp.style.filter = "alpha(opacity=60)";
  742.         }
  743.         // gray out down arrow if focus in on bottom button
  744.         if (nPosition == nTotal)
  745.         {
  746.             arrowDown.disabled = true;
  747.             arrowDown.style.filter = "alpha(opacity=20)"
  748.         }
  749.         else
  750.         {
  751.             arrowDown.disabled = false;
  752.             arrowDown.style.filter = "alpha(opacity=60)"
  753.         }
  754.     }
  755.     
  756.     /////////////////////////////////////////////////////////////////
  757.     // SetCounter
  758.     function setCounter()
  759.     {
  760.         //if page contains a scrolling button menu, set counter values
  761.         if (strScrollPage == "yes")
  762.         {
  763.             // Make the menu's item counter visible
  764.             itemCounterSpan.style.display = "block";
  765.             // Show total number of buttons in menu
  766.             counterNum.innerText = 1;
  767.             counterTotal.innerText = eval(nTotalBtns);
  768.         }
  769.     }
  770.  
  771.  
  772.     /////////////////////////////////////////////////////////////////
  773.     // Sounds
  774.     function playFocusSound()
  775.     {
  776.         btnSound.src = strFocusSound;
  777.     }
  778.  
  779.     function scrollElement(nCurFocus,intDirection,moveSpeed)
  780.     {
  781.         if (intDirection == 1)
  782.         {
  783.             if (((currentViewingDescription.offsetHeight - currentViewingDescription.parentElement.offsetHeight) - -currentViewingDescription.offsetTop) > -moveSpeed)
  784.                 movePixels = moveSpeed;
  785.             else
  786.                 movePixels = 0;
  787.         }
  788.         else
  789.         {
  790.             if (currentViewingDescription.offsetTop == 0)
  791.                 movePixels = 0;
  792.             else
  793.                 movePixels = -moveSpeed;
  794.         }
  795.     
  796.         currentViewingDescription.style.top = (currentViewingDescription.offsetTop - movePixels)
  797.     }
  798.  
  799.     // ----------------- Start code to scroll menu ------------------                         
  800.     function scrollMenu(nCurFocus)
  801.     {   
  802.         var nFocusBtnRow
  803.         //test for number of columns
  804.         try 
  805.         {
  806.             var nCols = nScrollMenuBtnCols
  807.         }
  808.         catch(e)
  809.         {
  810.             var nCols = 1
  811.         }
  812.  
  813.         // if selected item button is not on the scrolling menu table, gray-out counter and end function
  814.         if ((nCurFocus < nScrollMenuStartNo) || (nCurFocus > nScrollMenuEndNo))
  815.         {
  816.             var sClassname;
  817.             
  818.             sClassname = ""
  819.             try
  820.             {
  821.                 sClassname = eval("item" + nCurFocus + ".className");
  822.             }
  823.             catch(e)
  824.             {
  825.             }
  826.             if(sClassname.substring(0, 9) != "TextFrame")
  827.             {
  828.                 itemCounterSpan.style.filter = "alpha(opacity=50)";
  829.                 displayImages();
  830.             }
  831.             return;
  832.         }       
  833.          
  834.         // determine what position the current-focus button occupies in list table by
  835.         // subtracting the number of buttons that occur on the page before the 
  836.         // menu starts (nScrollMenuStartNo - 1) from the item number
  837.         // of the current-focus button (nCurFocus)
  838.         var nFocusBtnPosition = (nCurFocus - (nScrollMenuStartNo - 1));
  839.         
  840.         // determine what row in list table current-focus button occupies
  841.         if (Math.floor((nFocusBtnPosition) / nCols) < ((nFocusBtnPosition) / nCols))
  842.         {
  843.             nFocusBtnRow = (Math.floor((nFocusBtnPosition) / nCols) + 1)
  844.         }
  845.         else 
  846.         {
  847.             nFocusBtnRow = ((nFocusBtnPosition) / nCols)
  848.         }
  849.  
  850.         // reset counter
  851.         resetCounter(nCurFocus);
  852.  
  853.         // set a variable for the current position (# of button spaces offset) of 
  854.         // the top of the list table
  855.         var nTableTopPosition = (listTable.offsetTop / -(nBtnHeight));
  856.  
  857.         // determine whether the current-focus button is out of view, above or below; scroll accordingly
  858.         if (nFocusBtnRow > (nVisibleBtns + nTableTopPosition))
  859.         {
  860.             if ((nFocusBtnRow - (nVisibleBtns + nTableTopPosition)) > 1)
  861.                 movePixels = ((nBtnHeight) * (nFocusBtnRow - (nVisibleBtns + nTableTopPosition))) + nBtnHeight
  862.             else
  863.                 movePixels = (nBtnHeight) * (nFocusBtnRow - (nVisibleBtns + nTableTopPosition))
  864.             
  865.             // focus btn is below view, so scroll down
  866.             listTable.style.top = (listTable.offsetTop - movePixels)
  867.             displayImages();
  868.         }
  869.                 
  870.         if (nFocusBtnRow <= nTableTopPosition)
  871.         {
  872.             // focus btn is above view, so scroll up
  873.             listTable.style.top = ((nFocusBtnRow - 1) * -(nBtnHeight))
  874.             displayImages();
  875.         }
  876.     }
  877.     // ----------------- End code to scroll menu ------------------
  878.  
  879.     function displayImages()
  880.     {
  881.         listTop = listTable.style.top
  882.         
  883.         if (!listTop)
  884.             listTop = 0
  885.         else
  886.             listTop = parseInt(listTop)
  887.         
  888.         firstItem = ((-listTop / nBtnHeight) * nScrollMenuBtnCols) + 1;
  889.         
  890.         for (i = firstItem; i < firstItem + (nVisibleBtns * nScrollMenuBtnCols); i++)
  891.         {
  892.             currentImage = document.getElementById('thumbImage' + i);
  893.         
  894.             if (currentImage)
  895.             {        
  896.                 hiddenSrc = currentImage.hiddenSrc;
  897.                 
  898.                 currentImage.runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader()';
  899.                 
  900.                 itemFilter = currentImage.filters.item("DXImageTransform.Microsoft.AlphaImageLoader");
  901.                 
  902.                 if (itemFilter)
  903.                 {
  904.                     itemFilter.src = hiddenSrc;
  905.                     itemFilter.sizingMethod = 'scale';
  906.                 }
  907.             }
  908.             
  909.             currentText = document.getElementById('mediaText' + i);
  910.             
  911.             if (currentText)
  912.             {
  913.                 if (currentText.className != 'btnMediaText_focus')
  914.                     currentText.className = 'btnMediaText_nofocus';
  915.                 currentText.innerHTML = '<nobr>' + currentText.textValue + '</nobr>'
  916.             }
  917.         }
  918.     }
  919.  
  920.  
  921.     // ----------------- Start code to set non-selected menu to dormant ------------------
  922.     function setDormant(nCurFocus, prevItemNo)
  923.     // NOTE: this function does not work for every item; it is made to catch errors and ignore them
  924.     {
  925.         try
  926.         {
  927.             // if strDormantPage variable on HTML page is not set to "yes" then end function
  928.             if (strDormantPage != 'yes')
  929.             {
  930.                 return
  931.             }
  932.         }
  933.         catch(e)
  934.         {
  935.         // ignore error
  936.         }
  937.  
  938.         try
  939.         {
  940.             // find previous button
  941.             var oPrevBtn = eval('item' + prevItemNo);
  942.             // find outer tables for previous button
  943.             var oPrevParentTable = oPrevBtn.parentElement.parentElement.parentElement.parentElement;
  944.         }
  945.         catch(e)
  946.         {
  947.             //ignore error
  948.             // can't set previous item to dormant
  949.         }
  950.  
  951.         try
  952.         {
  953.             // find current button
  954.             var oCurrentBtn = eval('item' + nCurFocus);
  955.             // find outer tables for current button           
  956.             var oCurParentTable = oCurrentBtn.parentElement.parentElement.parentElement.parentElement;
  957.         }
  958.         catch(e)
  959.         {
  960.             //ignore error
  961.             // can't set current item to dormant
  962.         }
  963.         
  964.         // if previous and current buttons are in the same table, do nothing
  965.         try
  966.         {
  967.             if (oPrevParentTable == oCurParentTable)
  968.             {
  969.                 return
  970.             }
  971.         }
  972.         catch(e)
  973.         {
  974.             //ignore error
  975.         }
  976.  
  977.         try
  978.         {
  979.             // set previous-table items to dormant
  980.             if (oPrevBtn.scrollable != 'true')
  981.             {
  982.                 if (aFocusTableArray[(prevItemNo-1)].length > 9)
  983.                 {
  984.                 var enforcedGroup = aFocusTableArray[(prevItemNo-1)][9];
  985.             
  986.                 for (i=0; i < oPrevParentTable.cells.length; i++)
  987.                 {
  988.                     if (oPrevParentTable.cells(i).children(0))
  989.                     {
  990.                         if (oPrevParentTable.cells(i).children(0).className != '')
  991.                         {
  992.                             if(oPrevParentTable.cells(i).children(0).className.indexOf('_sep') < 0)
  993.                                 oPrevParentTable.cells(i).children(0).className=aFocusTableArray[(prevItemNo-1)][6];
  994.  
  995.                             if (nOrdinaryItems)
  996.                             {
  997.                                 for (j=0; j < nOrdinaryItems; j++)
  998.                                 {
  999.                                     if (oPrevParentTable.cells(i).children(0).id == 'item' + (j + 1))
  1000.                                     {
  1001.                                         if (oPrevParentTable.cells(i).children(0).checked == "yes")
  1002.                                             oPrevParentTable.cells(i).children(0).className=aFocusTableArray[j][6] + '_checked';
  1003.                                         else
  1004.                                             oPrevParentTable.cells(i).children(0).className=aFocusTableArray[j][6];                                
  1005.                                     }
  1006.                                 }
  1007.                             }
  1008.                         }
  1009.                     }
  1010.                 }
  1011.                 }
  1012.             }
  1013.             // reset type style in each cell
  1014.             oPrevParentTable.className=aFocusTableArray[(prevItemNo-1)][7];
  1015.             //if enforced item is in previous table, make it dormant too
  1016.             try
  1017.             {
  1018.                 if(eval(strEnforcedItem).parentElement.parentElement.parentElement.parentElement == oPrevParentTable)
  1019.                 { 
  1020.                     eval(strEnforcedItem).className = strEnforcedItemDormantStyle
  1021.                 }
  1022.                 if(eval(strSecondEnforcedItem).parentElement.parentElement.parentElement.parentElement == oPrevParentTable)
  1023.                 { 
  1024.                     eval(strSecondEnforcedItem).className = strEnforcedItemDormantStyle
  1025.                 }
  1026.             }
  1027.             catch(e)
  1028.             {
  1029.             //ignore error
  1030.             }
  1031.         }
  1032.         catch(e)
  1033.         {
  1034.         //ignore error
  1035.         }
  1036.  
  1037.         // set current button's menu to active (non-dormant)
  1038.         try
  1039.         {
  1040.             if (oCurrentBtn.scrollable != 'true')
  1041.             {
  1042.                 for (i = 0; i < oCurParentTable.cells.length; i++)
  1043.                 {    
  1044.                     if (oCurParentTable.cells(i).children(0))
  1045.                     {
  1046.                         if (oCurParentTable.cells(i).children(0).className != '')
  1047.                         {                    
  1048.                             if(oCurParentTable.cells(i).children(0).className.indexOf('_sep') < 0)
  1049.                                 oCurParentTable.cells(i).children(0).className=aFocusTableArray[(nCurFocus-1)][5];
  1050.                         
  1051.                             if (nOrdinaryItems)
  1052.                             {
  1053.                                 for (j=0; j < nOrdinaryItems; j++)
  1054.                                 {
  1055.                                     if (oCurParentTable.cells(i).children(0).id == 'item' + (j + 1))
  1056.                                     {
  1057.                                         if (oCurParentTable.cells(i).children(0).checked == "yes")
  1058.                                             oCurParentTable.cells(i).children(0).className=aFocusTableArray[j][5] + '_checked';
  1059.                                         else
  1060.                                         {
  1061.                                             if (aFocusTableArray[j][9] != '')
  1062.                                             {
  1063.                                                 if (aFocusTableArray[j][9] != aFocusTableArray[nCurFocus-1][9])
  1064.                                                 {
  1065.                                                     if ('item' + (j + 1) == strEnforcedItem)
  1066.                                                         eval('item' + (j + 1) + '.className=\'btn_nofocus_enforced_notcurrent\'')
  1067.                                                     else
  1068.                                                         eval('item' + (j + 1) + '.className=\'btn_nofocus\'')
  1069.                                                 }
  1070.                                                 else
  1071.                                                 {
  1072.                                                     if ('item' + (j + 1) == strEnforcedItem)
  1073.                                                         eval('item' + (j + 1) + '.className=\'btn_nofocus_enforced\'')
  1074.                                                     else
  1075.                                                         oCurParentTable.cells(i).children(0).className=aFocusTableArray[j][5];
  1076.                                                 }
  1077.                                             }
  1078.                                             else
  1079.                                                 oCurParentTable.cells(i).children(0).className=aFocusTableArray[j][5];
  1080.                                         }
  1081.                                     }
  1082.                                 }
  1083.                             }
  1084.                         }
  1085.                     }
  1086.                 }
  1087.             }
  1088.             // reset type style in all of parent table
  1089.             oCurParentTable.className=aFocusTableArray[(nCurFocus-1)][8];
  1090.             //if enforced item is in current table, make it active too
  1091.             try
  1092.             {
  1093.                 if(eval(strEnforcedItem).parentElement.parentElement.parentElement.parentElement == oCurParentTable)
  1094.                 {
  1095.                     //eval(strEnforcedItem).className = strEnforcedItemNoFocusStyle
  1096.                 }
  1097.                 if(eval(strSecondEnforcedItem).parentElement.parentElement.parentElement.parentElement == oCurParentTable)
  1098.                 {
  1099.                     //eval(strSecondEnforcedItem).className = strEnforcedItemNoFocusStyle
  1100.                 }
  1101.             }
  1102.             catch(e)
  1103.             {
  1104.             //ignore error
  1105.             }
  1106.         }
  1107.         catch(e)
  1108.         {
  1109.             //ignore error
  1110.         }
  1111.     }
  1112.     // ----------------- End code to set non-selected menu to dormant ------------------
  1113.  
  1114.  
  1115.     // ----------------- Start code to reset counter number values (for scrolling menus) ------------------
  1116.     function resetCounter(nCurFocus)
  1117.     {
  1118.         var nFocusBtnPosition = (nCurFocus - (nScrollMenuStartNo - 1));
  1119.         // un-gray counter
  1120.         itemCounterSpan.style.filter = "alpha(opacity=100)";
  1121.         // display position of currently selected btn in counter
  1122.         counterNum.innerText = eval(nFocusBtnPosition);
  1123.         // gray out up arrow if focus in on top button
  1124.         if (nCurFocus == nScrollMenuStartNo)
  1125.         {
  1126.             arrowUp.disabled = true;
  1127.             arrowUp.style.filter = "alpha(opacity=20)";
  1128.         }
  1129.         else
  1130.         {
  1131.             arrowUp.disabled = false;
  1132.             arrowUp.style.filter = "alpha(opacity=60)";
  1133.         }
  1134.         // gray out down arrow if focus in on bottom button
  1135.         if (nCurFocus == nScrollMenuEndNo)
  1136.         {
  1137.             arrowDown.disabled = true;
  1138.             arrowDown.style.filter = "alpha(opacity=20)"
  1139.         }
  1140.         else
  1141.         {
  1142.             arrowDown.disabled = false;
  1143.             arrowDown.style.filter = "alpha(opacity=60)"
  1144.         }
  1145.     }
  1146.     // ----------------- End code to reset counter number values  ------------------
  1147.  
  1148.  
  1149.     // --------------- Start code for Paging up/down (for scrolling menus) ---------------------------
  1150.     try 
  1151.     {
  1152.         var nPageDistance = ((nVisibleBtns * nBtnHeight) - nBtnHeight)        // Maximum distance to scroll for one "page" increment
  1153.     }
  1154.     catch(e)
  1155.     {
  1156.         nPageDistance = 0;
  1157.     }
  1158.     
  1159.     function pageDown()
  1160.     {
  1161.         // test to see if focus is on a table that should scroll
  1162.         // NOTE: this test assumes that the ID for your scrolling table is "ListTable"
  1163.         try
  1164.         {
  1165.             // If ID for scrollong table is not "listTable" then return.
  1166.             if (eval("item" + nCurFocus).parentElement.parentElement.parentElement.parentElement.id != "listTable")
  1167.             {
  1168.                 return
  1169.             };
  1170.         }
  1171.         catch(e)
  1172.         {
  1173.             return
  1174.         }
  1175.         // determine if listTable has cellspacing; will need to subtract extra spacing from bottom of table
  1176.         var nTablePadding = eval(listTable.getAttribute("cellspacing"));
  1177.         // variables
  1178.         nPageDistance = ((nVisibleBtns * nBtnHeight) - nBtnHeight);                        // Maximum distance to scroll for one "page" increment
  1179.  
  1180.         // if there is just one big selectable row showing at a time in the scrollable menu, treat paging down the same as
  1181.         // scrolling down one item at a time (call setFocus function, passing the down-arrow key code).
  1182.         if (nPageDistance < nBtnHeight)
  1183.         {
  1184.             SetFocus(1);
  1185.             return
  1186.         }
  1187.  
  1188.         var nMaxPageDistance = ((listTable.offsetHeight - nTablePadding) - nPageDistance); // Maximum total paging distance
  1189.         var nCurrentScrollAmnt = -listTable.offsetTop;                                     // amount already scrolled
  1190.         //test for number of columns
  1191.         try
  1192.         {
  1193.             var nCols = nScrollMenuBtnCols
  1194.         }
  1195.         catch(e)
  1196.         {
  1197.             var nCols = 1
  1198.         }
  1199.  
  1200.         // if selected item button is not on the scrolling menu table, end function
  1201.         if ((nCurFocus < nScrollMenuStartNo) || (nCurFocus > nScrollMenuEndNo))
  1202.         {
  1203.             return
  1204.         }
  1205.  
  1206.         var nFocusBtnPosition = (nCurFocus - (nScrollMenuStartNo - 1));
  1207.  
  1208.         // determine what row in list table current-focus button occupies
  1209.         if (Math.floor((nFocusBtnPosition) / nCols) < ((nFocusBtnPosition) / nCols))
  1210.         {
  1211.             nFocusBtnRow = (Math.floor(nFocusBtnPosition / nCols) + 1)
  1212.         }
  1213.         else
  1214.         {
  1215.             nFocusBtnRow = ((nFocusBtnPosition) / nCols)
  1216.         }
  1217.         // determine last row in menu
  1218.         var nLastRow = Math.floor((nScrollMenuEndNo - (nScrollMenuStartNo - 1)) / nCols)
  1219.  
  1220.         if (Math.floor((nScrollMenuEndNo - (nScrollMenuStartNo - 1)) / nCols) < ((nScrollMenuEndNo - (nScrollMenuStartNo - 1)) / nCols))
  1221.         {
  1222.             nLastRow = ((Math.floor((nScrollMenuEndNo - (nScrollMenuStartNo - 1)) / nCols)) + 1)
  1223.         }
  1224.         else
  1225.         {
  1226.             nLastRow = ((nScrollMenuEndNo - (nScrollMenuStartNo - 1)) / nCols)
  1227.         }
  1228.         // find which column current focus btn is in (multiply number of previous row by # of columns, and subtract from nFocusBtnPosition)    
  1229.         var nFocusCol = (nFocusBtnPosition - ((nFocusBtnRow - 1) * nCols));
  1230.         // bottom visible row
  1231.         var nBottomVisRowNo = ((nCurrentScrollAmnt / nBtnHeight) + nVisibleBtns);
  1232.         if (nBottomVisRowNo >= nLastRow)
  1233.         {
  1234.             nBottomVisRowNo = nLastRow;
  1235.         }
  1236.  
  1237.         // determine which button is in focus col of bottom visible row
  1238.         var nNewFocusPosition = (((nBottomVisRowNo -1) * nCols) + nFocusCol);
  1239.         var nNewFocusBtnNo = (nNewFocusPosition + (nScrollMenuStartNo - 1));
  1240.         if (nNewFocusBtnNo > nScrollMenuEndNo)
  1241.         {
  1242.             nNewFocusBtnNo = nScrollMenuEndNo;
  1243.         }
  1244.  
  1245.         // if menu has already scrolled to bottom, set focus to last button and end function
  1246.         if (listTable.offsetHeight <= ((nVisibleBtns * nBtnHeight) + nCurrentScrollAmnt + nTablePadding))
  1247.         {
  1248.             DrawFocus(nCurFocus, nNewFocusBtnNo, true);
  1249.             nCurFocus = nNewFocusBtnNo;
  1250.             DontSetFocusOnSeparator(1)
  1251.             //reset counter
  1252.             resetCounter (nCurFocus);
  1253.             return;
  1254.         }
  1255.  
  1256.         // If current-focus btn is not in bottom visible row, assign focus there, do resets, and end function
  1257.         if (nCurFocus != nNewFocusBtnNo)
  1258.         {
  1259.             DrawFocus(nCurFocus, nNewFocusBtnNo, true);
  1260.             nCurFocus = nNewFocusBtnNo;
  1261.             DontSetFocusOnSeparator(1)
  1262.             //reset counter
  1263.             resetCounter (nCurFocus);
  1264.             return
  1265.         }
  1266.  
  1267.         // move page down
  1268.         listTable.style.top = -(nCurrentScrollAmnt + nPageDistance);
  1269.         displayImages();
  1270.  
  1271.         // update variables
  1272.         nCurrentScrollAmnt = -listTable.offsetTop;
  1273.         nBottomVisRowNo = ((nCurrentScrollAmnt / nBtnHeight) + nVisibleBtns);
  1274.         if (nBottomVisRowNo >= nLastRow)
  1275.         {
  1276.             nBottomVisRowNo = nLastRow;
  1277.         }
  1278.  
  1279.         // update which button is in bottom visible row, focus col -- based on new position
  1280.         nNewFocusPosition = (((nBottomVisRowNo -1) * nCols) + nFocusCol);
  1281.         nNewFocusBtnNo = (nNewFocusPosition + (nScrollMenuStartNo - 1));
  1282.         if (nNewFocusBtnNo > nScrollMenuEndNo)
  1283.         {
  1284.             nNewFocusBtnNo = nScrollMenuEndNo;
  1285.         }
  1286.  
  1287.         //reset focus to bottom visible btn
  1288.         DrawFocus(nCurFocus, nNewFocusBtnNo, true);
  1289.         nCurFocus = nNewFocusBtnNo;
  1290.  
  1291.         DontSetFocusOnSeparator(1)
  1292.  
  1293.         //reset counter
  1294.         resetCounter (nCurFocus);
  1295.     }
  1296.  
  1297.  
  1298.     //----------------------------Page Up ---------------------------------------------
  1299.     function pageUp()
  1300.     {   
  1301.         // test to see if focus is on a table that should scroll
  1302.         // NOTE: this test assumes that the ID for your scrolling table is "ListTable"
  1303.         try
  1304.         {
  1305.             // If ID for scrollong table is not "listTable" then return
  1306.             if (eval("item" + nCurFocus).parentElement.parentElement.parentElement.parentElement.id != "listTable")
  1307.             {
  1308.                 return
  1309.             };
  1310.         }
  1311.         catch(e)
  1312.         {
  1313.             return
  1314.         }
  1315.  
  1316.         // In case any erroneous mouseover event calls useMouse function, set nMouseEvnet value to 0
  1317.         nMouseEvent = 0;
  1318.         // determine if listTable has cellspacing; will need to subtract extra spacing from bottom of table
  1319.         var nTablePadding = eval(listTable.getAttribute("cellspacing"));
  1320.         // variables
  1321.         nPageDistance = ((nVisibleBtns * nBtnHeight) - nBtnHeight);                         // Maximum distance to scroll for one "page" increment
  1322.  
  1323.         // if there is just one big selectable row showing at a time in the scrollable menu, treat paging up the same as
  1324.         // scrolling up one row at a time (to do this, call setFocus function, passing the up-arrow key code).
  1325.         if (nPageDistance < nBtnHeight)
  1326.         {
  1327.             SetFocus(0);
  1328.             return
  1329.         }
  1330.         var nMaxPageDistance = ((listTable.offsetHeight - nTablePadding) - nPageDistance);  // Maximum total paging distance
  1331.         var nCurrentScrollAmnt = -listTable.offsetTop;                                      // amount already scrolled
  1332.  
  1333.         //test for number of columns
  1334.         try 
  1335.         {
  1336.             var nCols = nScrollMenuBtnCols;
  1337.         }
  1338.         catch(e)
  1339.         {
  1340.             var nCols = 1;
  1341.         }
  1342.  
  1343.         // if selected item button is not on the scrolling menu table, end function
  1344.         if ((nCurFocus < nScrollMenuStartNo) || (nCurFocus > nScrollMenuEndNo)){
  1345.         return;
  1346.         }
  1347.  
  1348.         var nFocusBtnPosition = (nCurFocus - (nScrollMenuStartNo - 1));
  1349.  
  1350.         // determine what row in list table current-focus button occupies
  1351.         if (Math.floor((nFocusBtnPosition) / nCols) < ((nFocusBtnPosition) / nCols))
  1352.         {
  1353.             nFocusBtnRow = (Math.floor(nFocusBtnPosition / nCols) + 1);
  1354.         }
  1355.         else
  1356.         {
  1357.             nFocusBtnRow = ((nFocusBtnPosition) / nCols);
  1358.         }
  1359.  
  1360.         // find which column current focus btn is in (multiply number of previous row by # of columns, and subtract from nFocusBtnPosition)    
  1361.         var nFocusCol = (nFocusBtnPosition - ((nFocusBtnRow - 1) * nCols));
  1362.  
  1363.         // top visible row
  1364.         var nTopVisRowNo = ((nCurrentScrollAmnt / nBtnHeight) + 1);
  1365.  
  1366.         // determine which button is in target col of top visible row
  1367.         var nNewFocusPosition = (((nTopVisRowNo -1) * nCols) + nFocusCol);
  1368.  
  1369.         var nNewFocusBtnNo = (nNewFocusPosition + (nScrollMenuStartNo - 1));
  1370.  
  1371.         // if menu is already at top, set focus to top btn, reset counter, and end function
  1372.         if (listTable.offsetTop >= 0)
  1373.         {
  1374.             DrawFocus(nCurFocus, nNewFocusBtnNo, true);
  1375.             nCurFocus = nNewFocusBtnNo;
  1376.             DontSetFocusOnSeparator(0)
  1377.             resetCounter (nCurFocus);
  1378.             return;
  1379.         }
  1380.  
  1381.         // If focus is not on top visible button in column, assign focus there and end function    
  1382.         if (nCurFocus != nNewFocusBtnNo)
  1383.         {
  1384.             DrawFocus(nCurFocus, nNewFocusBtnNo, true);
  1385.             nCurFocus = nNewFocusBtnNo;
  1386.             DontSetFocusOnSeparator(0)
  1387.             // reset counter
  1388.             resetCounter (nCurFocus);
  1389.             return;
  1390.         }
  1391.  
  1392.         // move page up
  1393.         if ((-nCurrentScrollAmnt + nPageDistance) < 0) 
  1394.         {
  1395.             listTable.style.top = (-nCurrentScrollAmnt + nPageDistance);
  1396.         }
  1397.         else 
  1398.         {
  1399.             listTable.style.top = 0;
  1400.         }
  1401.         displayImages();
  1402.  
  1403.         // update variables
  1404.         nCurrentScrollAmnt = -listTable.offsetTop;
  1405.         nTopVisRowNo = ((nCurrentScrollAmnt / nBtnHeight) + 1);
  1406.         nNewFocusPosition = (((nTopVisRowNo -1) * nCols) + nFocusCol);
  1407.         nNewFocusBtnNo = (nNewFocusPosition + (nScrollMenuStartNo - 1));
  1408.  
  1409.         //reset focus to top visible btn
  1410.         DrawFocus(nCurFocus, nNewFocusBtnNo, true);
  1411.         nCurFocus = nNewFocusBtnNo;
  1412.  
  1413.         DontSetFocusOnSeparator(0)
  1414.  
  1415.         //reset counter
  1416.         resetCounter (nCurFocus);
  1417.     }
  1418.     // --------------------------------- End code for Paging up/down ----------------------------------------------------
  1419.  
  1420.  
  1421.     //----------------------------- Start code for switching to mouse ------------------------------------
  1422.     function useMouse(newItem)
  1423.     {
  1424.         if (nMouseEvent == 0)
  1425.         {
  1426.             nMouseEvent = 1;
  1427.             return;
  1428.         }
  1429.         var nNewItemNo = (newItem.children(0).id).substring(4);       
  1430.         var nPrevFocus = nCurFocus;
  1431.         nCurFocus = nNewItemNo;
  1432.         DrawFocus(nPrevFocus, nCurFocus, true);
  1433.     }
  1434.  
  1435.  
  1436.     // use if item is not in table
  1437.     function useMouse2(newItem)
  1438.     {
  1439.         if (nMouseEvent == 0)
  1440.         {
  1441.             nMouseEvent = 1;
  1442.             return;
  1443.         }
  1444.         var nNewItemNo = newItem.id.substring(4);
  1445.         var nPrevFocus = nCurFocus;
  1446.         nCurFocus = nNewItemNo;
  1447.         DrawFocus(nPrevFocus, nCurFocus, true);
  1448.     }
  1449.     //----------------------------- End of code for switching to mouse ------------------------------------
  1450.  
  1451.  
  1452.     // Temporary "highlight" effect when button is clicked  state, or clicked state
  1453.     function btnHiLite (srcBtn, style)
  1454.     {
  1455.         try
  1456.         {
  1457.             if ((strEnforcedItem == srcBtn.id) && (window.event.type == 'mouseup'))
  1458.             {
  1459.                 style = strEnforcedItemFocusStyle;
  1460.             }
  1461.             if ((strSecondEnforcedItem == srcBtn.id) && (window.event.type == 'mouseup'))
  1462.             {
  1463.                 style = strEnforcedItemFocusStyle;
  1464.             }
  1465.         }
  1466.         catch(e)
  1467.         {
  1468.         }
  1469.         srcBtn.className = style;
  1470.     }
  1471.  
  1472.  
  1473.     // Set button for enforced state (add code as necessary)
  1474.     function btnEnforced(btn)
  1475.     {
  1476.     }
  1477.  
  1478.     //----------------------------- Start code for Spinner control ------------------------------------
  1479.     // args are: (string to indicate whether to move up or down, number to identify which spinner to set)
  1480.     function countSpinner(sPlusMinusStr, nSpinnerNumber)
  1481.     {
  1482.         // check for disabled button
  1483.         if (eval("item" + nCurFocus).disabled == true)
  1484.         {
  1485.             return
  1486.         }
  1487.  
  1488.         // determine which array to use
  1489.         var sCurrentArray = "aSpinnerArray" + nSpinnerNumber
  1490.         // determine which element is currently shown
  1491.         var nTempElementCount = eval("aSpinnerArray" + nSpinnerNumber).count
  1492.         // if user clicked Plus, move element count forward by one
  1493.         if (sPlusMinusStr == "plus")
  1494.         {
  1495.             nTempElementCount = nTempElementCount + 1
  1496.         }
  1497.         // if user clicked Minus, move element count back by one
  1498.         if (sPlusMinusStr == "minus")
  1499.         {
  1500.             nTempElementCount = nTempElementCount - 1
  1501.         }
  1502.  
  1503.         // Call function to set spinner text
  1504.         setSpinner(sCurrentArray, nSpinnerNumber, nTempElementCount)
  1505.  
  1506.         // disable plus/minus buttons as needed
  1507.         if (nTempElementCount >= eval(sCurrentArray).length -1)
  1508.         {
  1509.             // disable second button in span (should be plus button)
  1510.             eval("item" + nCurFocus).parentElement.children[1].disabled = true
  1511.         }
  1512.         else
  1513.         {
  1514.             // enable second button in span (should be plus button)
  1515.             eval("item" + nCurFocus).parentElement.children[1].disabled = false
  1516.         }
  1517.  
  1518.         if (nTempElementCount <= 0)
  1519.         {
  1520.             // disable first button in span (should be minus button)
  1521.             eval("item" + nCurFocus).parentElement.children[0].disabled = true
  1522.         }
  1523.         else
  1524.         {
  1525.             // enable first button in span (should be minus button)
  1526.             eval("item" + nCurFocus).parentElement.children[0].disabled = false
  1527.         }
  1528.  
  1529.         //reset element count    
  1530.         eval(sCurrentArray).count = nTempElementCount;
  1531.     }
  1532.  
  1533.  
  1534.     /////////////////////////////////////////////////////////////////
  1535.     // setSpinner
  1536.     function setSpinner(sCurrentArray, nSpinnerNumber, nTempElementCount)
  1537.     {
  1538.         //determine which spinner box to update
  1539.         var oCurBox = eval("spinnerBox" + nSpinnerNumber)
  1540.         // update box text with contents of array element
  1541.         oCurBox.innerHTML = (eval(sCurrentArray)[nTempElementCount]);
  1542.     }
  1543.  
  1544.     function setBGColor()
  1545.     {
  1546.         try
  1547.         {
  1548.             window.external.MediaCenter.BGColor = "#0F4A96"
  1549.         }
  1550.         catch(ex)
  1551.         {
  1552.         }
  1553.     }
  1554.